<%-- 
    Document   : Content_DealDetail
    Created on : Oct 20, 2011, 8:31:40 PM
    Author     : Administrator
--%>

<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="dao.DonDatHang_DAO"%>
<%@page import="pojo.Dondathang"%>
<%@page import="dao.HinhAnh_DAO"%>
<%@page import="pojo.Hinhanh"%>
<%@page import="java.util.ArrayList"%>
<%@page import="dao.Deal_DAO"%>
<%@page import="pojo.Deal"%>
<%@page import="java.text.DecimalFormat"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
    //ArrayList<Deal> ds = (ArrayList<Deal>) request.getAttribute("dealTheoDanhMuc");
    Deal mau = (Deal) request.getAttribute("DEAL");
    ArrayList<Hinhanh> ds = HinhAnh_DAO.layHinhAnhTheoMaDeal(mau.getId());
    double giaThuong = mau.getGiaThuong();
    double giaDaGiam = mau.getGiaDaGiam();
    double tietKiem = giaThuong - giaDaGiam;
    double a = 100 - (giaDaGiam / giaThuong) * 100;
    int phanTram = (int) a;
    DecimalFormat df = new DecimalFormat(",###");
    String giaThuong1 = String.valueOf(df.format(giaThuong));
    String giaDaGiam1 = String.valueOf(df.format(giaDaGiam));
    String tietKiem1 = String.valueOf(df.format(tietKiem));
    int maDeal = (int) mau.getId();
    int tongSoDealDaDat = DonDatHang_DAO.demSoDealTrongDonDatHangTheoMaDeal(maDeal);
    // 0 nếu Deal thỏa diều kiện và vẫn đang được bán
    // 1 nếu Deal này hết hạn
    // 2 nếu Deal này cháy hàng
    int trangThaiDeal = Deal_DAO.TrangThaiDeal(maDeal);



%>
<div class="div_TopLInfoMC">
    <i class="div_LTopInfo"></i>
    <div class="div_LBodyInfo">
        <i class="div_LBodyTop"> </i>

        <div class="div_TextInfoDay">
            <h2 id="hTitleDeal" class="styleText3" style="font-size:19px">
                <a href='mu-bao-hiem-big-one-7F010505077C.html' style='font-size:20px;color:#FBFBFB'>
                    <strong class='color15' style='font-size:23px'>Giá tốt hôm nay:</strong>
                    <%=mau.getTieuDeDeal()%>
                </a>
            </h2>
        </div>
        <div class="div_InfoProduct">
            <div id="divLikeFace" class="div_LikeFace" style="text-align:right">
                <g:plusone size="medium">
                </g:plusone><fb:like class=' fb_edge_widget_with_comment fb_iframe_widget'  layout='button_count' send='true' href='mu-bao-hiem-big-one-7F010505077C.html'></fb:like></div>
            <div id="fb-root" style="float:right" class=" fb_reset"></div>
            <div class="div_LInfoGroupOn">
                <p class="div_FillBgGroupOn"></p>
                <div class="div_bgGroupOn ">
                    <div id="divTietKiem" class="div_TietKiem"><strong class='styleText4'>Tiết Kiệm</strong><br/><strong class='safeUp'><%=phanTram%>%</strong></div>

                    <div id="divPriceDown" class="divPrice">
                        <span class='styleText4'>Giá trị:
                            <strong class='StyleTextGT lineHorizontal styleText2'><%=giaThuong1%></strong>
                        </span>
                        <div class='div_VND GTVND'>
                            <strong class='styleText13'>VND</strong>
                        </div><br/>
                        <span class='styleText4 spTietKiem'>Tiết kiệm:
                            <strong class='StyleTextGT styleText2'><%=tietKiem1%></strong>
                        </span>
                        <div class='div_VND TKVND'><strong class='styleText13'>VND</strong></div></div>
                    <div id="divPrice" style="height:73px;">
                        <div class='div_infoMoney'>
                            <div class='div_TextInfoMoney'>
                                <p class='styleText7'><strong>Còn Lại</strong>
                                    <strong class='strVNDMoney'>VND</strong></p>
                                <p class='pGiaTienID'>
                                    <strong class='safeUp'><%=giaDaGiam1%></strong>
                                </p>
                            </div>
                            <div id='divBuy'>
                                <%
                                    if (trangThaiDeal == 1) {
                                %>
                                <div id='divBuy'>
                                    <div class='div_buttonHetHan'></div>
                                </div>
                                <%} else {%>
                                <div class='div_buttonMua'>
                                    <a href='xl_MuaDeal?Action=Buy&DealID=<%=mau.getId()%>' style='display:block' class='btnMua' id='btnBuyDeal'>Mua</a>
                                </div>
                                <%}%>
                            </div>
                        </div>
                    </div>
                    <%if (trangThaiDeal == 1 || trangThaiDeal == 3) {%>
                    <div class="div_MuaTangBB"><p class="div_bgQuaTang aNonebgQuaTang "></p><p  class="aTextQuaTang">Mua tặng bạn bè!</p></div>
                    <%} else {%>
                    <div class="div_MuaTangBB"><p class="div_bgQuaTang "></p><p  class="pTimeCLNew styleText2pTimeCLNew styleText2">Mua tặng bạn bè!</p></div>
                    <%}%>
                </div>
                <div id="divRemainTime">

                    <div class="div_TimeCLMC">
                        <div class="div_LeftTimeCLMC"></div>

                        <div class="div_CenterTimeCLMC hide">
                            <p class="pTimeCLNew styleText2"><strong>Thời gian còn lại:</strong></p>
                            <div class="div_bgEachTime firstEachTime"><strong class="safeUp">48</strong></div>
                            <div class="div_bgEachTime"><strong class="safeUp">48</strong></div>

                            <div class="div_bgEachTime"><strong class="safeUp">48</strong></div>
                            <p class="p_bgEachTime firstEachTime styleText8 color4">giờ</p>
                            <p class="p_bgEachTime styleText8 color4">phút</p>
                            <p class="p_bgEachTime styleText8 color4">giây</p>
                        </div>

                        <div class="div_CenterTimeCLMC hide">
                            <p class="pTimeCLNew styleText2"><strong></strong></p>

                            <div class="div_TimeHH"></div>
                        </div>
                        <div class="div_RightTimeCLMC"></div>
                    </div>

                    <div class="div_BuyerMua hide">

                        <div class="div_NumberBuyer hide">
                            <div class="div_LeftNumberBuyer"></div>
                            <div class="div_BodyNumberBuyer"><p class="color9 styleText2 pPeopleBuyer"><strong class="safeUp"></strong></p-></div>
                            <div class="div_RightNumberBuyer"></div>

                        </div>
                        <div class="bg_StatusGroupOn">
                            <div class="div_bg_StatusBuyer_Yellow" style="width:109px;">
                                <i class="bg_StatusBuyer_Yellow"></i>
                            </div>
                        </div>
                        <p class="styleText8  pBuyer"></p>
                    </div>
                    <div class="div_StatusMC hide">
                        <div class="div_LStatusMC"></div>
                        <div class="div_BodyStatusMC hide">
                            <span class="spCheckHH"></span>
                            <p class="pDatDcSMC styleText7"></p>
                            <p class="pBuyerMC"></p>
                            <p class="ptextPeople styleText7"></p>
                        </div>
                        <div class="div_BStatusMH divBStatusHH" id="divNumberSold">                                        
                        </div>
                        <div class="div_RStatusMC"></div>
                    </div>
                </div>
                <br/>
                <a href="../../winner/index.html" id="aWinC7" target="_blank" class="WinC7" style="display:none"></a> 
                <div id="divWriteComment">
                    <i class="dCamNhanCM"></i>
                    <a href="../../indexa65d.html?cID=090107050806&amp;f=0" id="aWriteComment" class="btnGui" style="position:relative;margin-left:40px;float:left">Viết Cảm Nhận</a> 
                </div>
            </div>


            <div class="div_RInfoProduct">
                <div class="div_TopRIProduct">
                    <div id="divTitleIMG" class="div_bgMailYahoo tranparent colorBGMail"></div>

                    <div class="div_infoImgShow"><a href="#"><strong class="styleText9 color13" id="strTitleIMG"></strong></a></div>
                    <a href="#" id="aimgIndexBig1" class="aImgBigShow"><img id="imgShow1" width="480" height="297" /></img></a>
                    <a href="#" id="aimgIndexBig2"  class="aImgBigShow hide"><img id="imgShow2" width="480" height="297" /></img></a>    
                    <div id="divTitleChayhang" class="div_titleChayHang" style="display:none"></div>                           
                </div>
                <div class="div_listProduct" id="div_MainLIMG">
                    <div class="dFocusImgShow" id="dFocusImgShow"></div>
                    <div class="div_btListIMG buttonPre" id="btnPreIMG"></div>
                    <div class="div_btListIMG buttonNext" id="btnNextIMG"></div>
                    <div class="div_MainListImgI" id="div_IMGList">                           			
                    </div>

                </div>
                <div class="div_HighLight">
                    <i class="div_TopHighLight"></i>
                    <div id="divDealInfo" class="div_BodyHighLight">
                        <div class='div_LBodyHL'>
                            <h4 class='styleText2 color16'>Điểm nổi bật</h4><br/>
                            <div class='styleText7 color3 pTextTopHL'>
                                <%=mau.getDacDiemNoiBat()%>
                            </div>
                        </div>
                        <div class='div_RBodyHL'><h4 class='styleText2 color16'>Điều kiện</h4>
                            <div class='styleText7 color3 pTextTopHL'>
                                <%=mau.getDieuKien()%>
                            </div></div></div>
                    <i class="div_BTHighLight"></i>
                </div>
            </div>

        </div>

    </div>

    <i class="div_LBottomInfo"> </i>
</div>

<div class="div_Company">
    <div class="div_TopCom"></div>
    <div class="div_bodyCom">
        <div class="div_titleCom">
            <div class="div_xinchao"></div>
            <div class="div_TextTitleCom "><h2 class="styleText9 color5">Thông tin</h2></div>
        </div>
        <div id="divCompanyInfoL" class="div_infoShop"><p style="text-align: center;">
                <%=mau.getNoiDungDeal()%>
        </div>
        <div class="div_RinfoCom">
            <div class="div_RTopInfoCom"></div>
            <div id="divCompanyInfoR" class="div_RbodyICom">
                <div class='div_RTitleCom' >
                    <strong class='styleText9 color6' style='font-size:18px'><%= mau.getTenCongTy()%></strong>
                </div>
                <div class='div_RBodyCom'>
                    <div class='color6 styleText10 pDiachiTest'>
                        <span class='spnIconAddr'><strong>1</strong><i></i></span>
                        <div style='padding-top:8px;'>
                            <a target='_blank' href='http://www.diadiem.com/vn/vnMap.aspx?st=HaNoi&amp;h=1&amp;cID=090107040207' title='<%= mau.getTenCongTy()%>' class='Addr'><%=mau.getDiaChi()%></a>
                        </div>
                    </div>
                    <div class='color6 styleText10 pPhone' style='width:170px'>
                        <span>Ðiện thoại:</span>
                    </div>
                    <div style='padding-top:0px;' class='color6 styleText10 pPhone'>
                        <strong><%=mau.getDienThoai()%></strong>
                    </div>


                </div>
            </div>
            <div class="div_RBInfoCom"></div>
            <a href="http://www.nokia.com.vn/c7?utm_source=NhomMua&amp;utm_medium=NM&amp;utm_campaign=NM" id="aLinkC7" target="_blank" style="display:none;background:url(http://www.nhommua.com/ha-noi/deals/images/aLinkNoki.png) no-repeat scroll 0 0;width:254px;height:81px;margin:4px 0 0 -30px;float:left;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/aLinkNoki.png,sizingMethod=crop);_background-image:none;"></a>
        </div>

        <div id="divMapParent" class="div_map" style="overflow:hidden;width:605px;margin-left:38px;position:relative">
            <div id="divMap" style="position:absolute;height:295px; overflow: hidden; width: 599px;"><a href='http://www.diadiem.com/vnMap.aspx?lID=0D03090801&amp;st=HaNoi&amp;zm=25&amp;mt=0' target='blank'><img src='http://images.diadiem.com/Profiles/snapshot/2011/8/18/57423720118181528454193046.jpeg' border='0' /></a></div>
        </div>
    </div>
    <div class="div_BotCom"></div>
</div>

<%
    // mau.getSoLuongDeal()
    //      mau.getNgayBatDau()
    //     mau.getNgayKetThuc()
    //    mau.getSoLuongDealToiThieu()
    //  mau.getSoLuongDealTrenMotNguoi()
    Date todayD = new Date(System.currentTimeMillis());
    SimpleDateFormat dayFormat = new SimpleDateFormat("dd/MM/yyyy");
    String todayS = dayFormat.format(todayD.getTime());
    Date nBatDau = mau.getNgayBatDau();
    Date nKetThuc = mau.getNgayKetThuc();
    String ngayBatDau = dayFormat.format(nBatDau.getTime());
    String ngayKetThuc = dayFormat.format(nKetThuc.getTime());
    SimpleDateFormat timeFormat = new SimpleDateFormat("hh:mm:ss");
    String time = timeFormat.format(todayD.getTime());

%>                 
<script type="text/javascript">
    //<![CDATA[
    var strStateNM='ha-noi' ;var strDeal={"id":"7F0102090D7C",
        "ngaykt":"<%=ngayKetThuc%>",
        "giokt":"23\:59\:59",
        "ngayhl":"<%=ngayBatDau%>",
        "giohl":"23\:59\:59\:0",
        "CurDay":"<%=todayS%>",
        "CurTime":"<%=time%>",<%int soLuongMuaToiThieu = mau.getSoLuongDealToiThieu();
            if (tongSoDealDaDat >= soLuongMuaToiThieu) {%>
                    "ok":"True",<%} else {%>"ok":"False",<%}%>
                    "sltd":"<%= mau.getSoLuongDeal()%>",
                    "sltt":"<%= mau.getSoLuongDealToiThieu()%>",
                    "sldb":"<%=tongSoDealDaDat%>",
                    "countsolddown":"<%=tongSoDealDaDat%>",
    <%if (trangThaiDeal == 3) {%>
                "statussolddown":"True",
    <%} else {%>
                "statussolddown":"False",
    <%}%>
                "chayhang":"10h",
    <%if (trangThaiDeal == 1) {%>
                "status":"True"};
    <%} else {%>
            "status":"False"};
    <%}%>
        // STATUS : the hien trang thai mua Deal True "Hết Hạn giảm giá" -- Hien thi ngay het ban Deal và thong ke so nguoi mua Deal gia tot
        // CHAY HANG : Thông báo thời gian cháy hàng (Cháy hàng khi so Deal được mua trước ngày hết hạn)
        // STATUS SOLD DOWN : Thông báo thời gian cháy Deal "Bán hết trong vòng..." Deal thống kê người mua giá tốt Nếu item này la True thi lấy giá trị cua SLDB
        // SLDB : Số lượng Deal đã bán
        // COUNT SOLD DOWN : Đếm số lượng Deal đã bán nếu STATUS = True hiện thị Item này 
        // SLTT : số lượng Deal tối thiểu cần bán được để được giá tốt
        // SLTD : số lượng Deal tối đa
        // OK : Bật thanh đếm số lượng người mua nếu chưa đủ người mua để được giá tốt
        var strPhotos={"dsPhoto":[
    <%
            for (int i = 0; i < ds.size(); i++) {
                Hinhanh ha = ds.get(i);
                if (ha.getKieuHinh().equals("Slide")) {
    %>
                {"idphoto":"32409","idsp":"7F0102090D7C","link":"<%=ha.getUrl()%>","title":"<%=mau.getTileSmallDeal()%>"},<%}
                    }%>
                        ]};var strFaceBook ='';var objRefer='';//]]>
</script>    


